﻿@model IEnumerable<JustMVCTest.Models.PO>
@using JustMVCTest.Models
@{
    ViewBag.Title = "History";
}

<h3 align="right"> <a href="@Url.Action("Index", "POsList")">  Back  </a> </h3>

<font size="3" color="blue"> <b> History Details for  PO Number: @Html.DisplayFor(modelItem => modelItem.First().PONumber) Item Number: @Html.DisplayFor(modelItem => modelItem.First().Item) </b> </font>

  <br/>  <br/>


    <fieldset>
        <legend>Details</legend>

<br/>

 @(Html.Telerik().Grid<PO>(Model)
        .Name("POesGrid")
        .DataKeys(keys =>
        {
            keys.Add(p => p.PONumber);
            keys.Add(p => p.Item);
            keys.Add(p => p.Update_Num);
        })
        .Columns(columns =>
        {
            columns.Template(@<form name="pickform" action="@Url.Action("Index", "History")"> 
            <input type="hidden" value="@item.Item" name= "Item"/> <input type="hidden" value="@item.PONumber" name= "PONumber"/>
             <input style="font-size:small" type="submit" value="History" /> </form>).Title("Commands").Width(80);
            columns.Bound(o => o.PONumber).Width(100);
            columns.Bound(o => o.Item).Width(50);

            columns.Bound(o => o.Descr).Width(100);

            columns.Bound(o => o.DeliveryDate).Width(150).Format("{0:d}");

            columns.Template(@<script type="text/javascript">
                                   var x = @item.Status
                                   if (x == '1') {
                                       document.write("Pending Close");
                                   }
                                   if (x == '2') {
                                       document.write("Pending Delivery Date");
                                   }
                                   if (x == '0') {
                                       document.write("Open");
                                   }
                                   if (x == '99') {
                                       document.write("Closed");
                                   }

                    </script>).Title("Status").Width(100);

                columns.Bound(o => o.Requisitioner).Width(100);

                columns.Bound(o => o.DeliveryDate_Req).Width(150).Format("{0:d}");
   
                columns.Bound(o => o.Cost_Cent).Width(100);
  
                columns.Bound(o => o.Int_Order).Width(100);
  
                columns.Bound(o => o.Prof_Cent).Width(100);

                columns.Bound(o => o.Percentage).Width(100);

                columns.Bound(o => o.cost_elem).Width(100);

                columns.Bound(o => o.co_el_name).Width(100);

                columns.Bound(o => o.Vendor).Width(100);

                columns.Bound(o => o.VendorName).Width(100);
   
                columns.Bound(o => o.UM).Width(100);

                columns.Bound(o => o.T_Curr).Width(100);
 
                columns.Bound(o => o.Sch_Lin).Width(100);

                columns.Bound(o => o.Ord_Qty).Width(100);

                columns.Bound(o => o.Open_Qty).Width(100);

                columns.Bound(o => o.Open_Amt_T).Width(100);

                columns.Bound(o => o.Order_Amt).Width(100);

                columns.Bound(o => o.Open_Amt_L).Width(100);


        })

        .CellAction(cell =>
        {
            if (cell.Column.Member == "Status")
            {
                PO po = cell.DataItem;
 
                
            }
        })


         .Pageable()
         .Scrollable()
         .Sortable()


    )

</fieldset>
